package cn.liumouren.jzxd.dao;

import cn.liumouren.jzxd.entity.Scene;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Freeman Liu
 * @email llw599502537@gmail.com
 * @date 2020-10-30 16:28:21
 */
@Mapper
public interface SceneDao extends BaseMapper<Scene> {

    @Select("<script>" +
            "SELECT DISTINCT tb_scene.* FROM tb_scene,tb_scene_tag WHERE tb_scene.`id` = tb_scene_tag.`scene_id` AND tb_scene_tag.`tag_id` IN" +
            "  <foreach collection='tagIds' item='id' open='(' separator=',' close=')'>" +
            "  #{id}" +
            "  </foreach> " +
            "</script>")
    IPage<Scene> getSceneByTagIds(IPage<Scene> scenePage, List<String> tagIds);
}
